package homework.test1;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class ServiceDemo1 {
    public static void main(String[] args) throws IOException {
        //3.服务器确定接收地址
        ServerSocket ss = new ServerSocket(10001);

        //4.监听客户端连接
        System.out.println("----服务器接收中----");
        Socket sk = ss.accept();
        System.out.println("----服务器已接收----");

        //5.输入
        InputStream is = sk.getInputStream();
        byte [] bytes = new byte[1024];
        int len;
        while ((len = is.read(bytes)) != -1){
            String s = new String(bytes,0,len);
            System.out.println("服务器："+s);
        }

        is.close();
        sk.close();
        ss.close();
    }
}
